package com.kayo.specimen.service;

import com.kayo.specimen.dao.MenuMapper;
import com.kayo.specimen.model.Menu;
import com.kayo.specimen.model.view.MenuView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

@Service("menuService")
public class MenuServiceImpl implements MenuService {

    @Autowired
    private MenuMapper menuMapper;

    @Override
    public int addMenus(Menu... menus){
        for(Menu menu:menus){
            menu.setId(UUID.randomUUID().toString());
        }
        return menuMapper.insert(menus);
    }

    @Override
    public List<MenuView> getMenus(String id, String name, String url, String privilegeId, String category, String order){
        return menuMapper.select(id,name,url,privilegeId,category, order);
    }

    @Override
    public int updateMenus(Menu... menus){
        return menuMapper.update(menus);
    }

    @Override
    public int removeMenus(String... menuId){
        return menuMapper.delete(menuId);
    }
}
